<?php
/**
 * 查询天气信息
 * @project berfen
 * @copyright 院主互联网数据
 * @author yuanzhumc
 * @version 1.0
 * @date: 2021/5/27
 * @createTime 9:15
 * @filename index.php
 * @product_name PhpStorm
 * @link
 * @example
 */

$receive_data=[
    'city'=>'北京'
];

$url = 'http://wthrcdn.etouch.cn/weather_mini?city='.urlencode($receive_data['city']);
$html = file_get_contents($url);
$jsondata = gzdecode($html);
$data=json_decode($jsondata,true);

$result_data=[
    'city'=>$receive_data['city'],
    'ganmao'=>$data['data']['ganmao'],
    'yesterday'=>$data['data']['yesterday'],
    'today'=>$data['data']['forecast'][0],
    'forecast'=>$data['data']['forecast'],
];

print_r($result_data);